<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Add Customer</title>
<link rel="stylesheet" type='text/css' href='css/style.css' />
<script type="text/javascript" src="js/rightclick.js"></script>
</head>
<body>

<div class="container" >

	<div class="navbar">
	<p>
		<a href="HostServlet" class="navbutton">Home</a> | <a href="ViewTables" class="navbutton">Tables</a> | <a href="Reservation" class="navbutton">Reservations</a>
	</p>
	</div>
	
			<c:choose>
				<c:when test="${ edit != null }">
				
				<div class='formcontainer'>
				
					<FORM METHOD=POST ACTION="AddCustomer" CLASS="formalignright">
					<label for='firstName'>First Name: </label><INPUT TYPE=TEXT VALUE="${ editthiscustomer.firstName }" NAME=firstName SIZE=20 class='addcustinput'><BR />
					<label for='lastName'>Last Name: </label><INPUT TYPE=TEXT VALUE="${ editthiscustomer.lastName }" NAME=lastName SIZE=20 class='addcustinput'><BR />
					<label for='address'>Address: </label><INPUT TYPE=TEXT VALUE="${ editthiscustomer.address }" NAME=address SIZE=20 class='addcustinput'><BR />
					<label for='phone'>Phone: </label><INPUT TYPE=TEXT VALUE="${ editthiscustomer.phoneNumber }" NAME=phone SIZE=20 class='addcustinput'><BR />
					<input type="hidden" VALUE="${ editthiscustomer.id }" name="customerId" />
					<INPUT TYPE=SUBMIT VALUE="Edit" name="edit" class='loginbutton'>
					</FORM>
				
				</div>
				
				</c:when>
				<c:otherwise>
				
				<div class='formcontainer'>
				
					<FORM METHOD=POST ACTION="AddCustomer"  CLASS="formalignright">
					First Name: <INPUT TYPE=TEXT NAME=firstName SIZE=20 class='addcustinput'><BR />
					Last Name: <INPUT TYPE=TEXT NAME=lastName SIZE=20 class='addcustinput'><BR />
					Address: <INPUT TYPE=TEXT NAME=address SIZE=20 class='addcustinput'><BR />
					Phone: <INPUT TYPE=TEXT NAME=phone SIZE=20 class='addcustinput'><BR />
					<INPUT TYPE=SUBMIT VALUE="Add" name="add" class='loginbutton'>
					</FORM>
				
				</div>
				
				</c:otherwise>
			</c:choose>
			
			<p />
			
			<c:if test="${ addsuccessful != null }">
			
			Customer Successfully Added!
			
			</c:if>
			
			<c:if test="${ editsuccessful != null }">
			
			Customer Successfully Edited!
			
			</c:if>
			
			<p />
			
			<FORM METHOD=POST ACTION="AddCustomer"  CLASS="findcustform">
			Check Customer: <INPUT TYPE=TEXT NAME="keyword" SIZE=20><BR />
			<INPUT TYPE=SUBMIT VALUE="Find" NAME="findcustomer" class='loginbutton'>
			</FORM>
			
			<c:if test="${ searched != null }">
			<p></p>
			
			<c:choose>
		
				<c:when test = "${ empty customerresult[0] }">
				
				Customer not found. Create a record!
				
				</c:when>
			
			<c:otherwise>
			
				<table  class="customertable">
				<thead>
					<tr>
						<th>First</th><th>Last</th><th>Address</th><th>Phone</th><th></th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${ customerresult }" var="customer">
						<tr><td>${customer.firstName}</td><td>${customer.lastName}</td><td>${customer.address}</td><td>${customer.phoneNumber}</td><td id='opaq'><a class='tablebutton' href="AddCustomer?editcustinfo=${customer.id}">Edit Info</a></td></tr>
					</c:forEach>
				</tbody>
				</table>
			
			</c:otherwise>
			
			</c:choose>
			
			</c:if>



</div>

</body>
</html>